package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class RedidSessionController {

    @Value("${server.port}")
    public String port;

    @PostMapping("/save")
    public String saveName(String name, HttpSession session) {
        session.setAttribute("name", name);
        return "hello," + name + ":" + port;
    }

    @PostMapping("/get")
    public String getName(HttpSession session) {
        session.getAttribute("name");
        return "hello," + session.getAttribute("name") + ":" + port;
    }
}
